//
//  VisitorTableViewController.swift
//  weibo
//
//  Created by 吴婷婷 on 15/11/4.
//  Copyright © 2015年 wutingting. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {
    
    private var userLogon = UserAccountViewModel.sharedUserAccount.userLogon
    
    var visitorView: VisitorView?
    
    override func loadView() {
        userLogon ? super.loadView() : setUpVisitorView()
    }
    
    func setUpVisitorView(){
        //替换根视图
        visitorView = VisitorView()
        view = visitorView
        
        //添加监听方法
        visitorView?.registerButton.addTarget(self, action: "visitorLoginViewDidRegister", forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.loginButton.addTarget(self, action: "visitorLoginViewDidLogin", forControlEvents: UIControlEvents.TouchUpInside)
//        visitorView.backgroundColor = UIColor.redColor()
        
        //设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorLoginViewDidRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "visitorLoginViewDidLogin")
        
    }
    //MARK: - 访客视图监听方法
    func visitorLoginViewDidRegister(){
        print("注册")
    }
    
    func visitorLoginViewDidLogin(){
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
}


